<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/13
 * Time: 11:11
 */

namespace app\home\controller;

class Index extends common
{
    //首页
    public function index(){
        //用户信息
        $user = session('user');
        if(!$user){
            $this->error('账号未登录!','login/login');
        }
        $type = input('get.type',"","intval");
        $data['user_pic'] = $user['user_pic'];
        $data['name'] = $user['name'];
        $db = empty($type)?db('ssc'):db('ptc');
        //最近一期的开奖信息
        $ssc = $db
            ->where('opencode','like','%,%,%,%,%')
            ->where('expect','like',date('Ymd').'%')
            ->order('expect desc')
            ->limit(1)
            ->find();
        if($ssc ['handcode'] != '--'){
            $code['opencode'] = $ssc ['handcode'];
        }else{
            $code['opencode'] = $ssc ['opencode'];
        }
        $code['expect'] = $ssc['expect'];
        $info['user'] = $data;
        $info['code'] = $code;
        //夺宝记录
        $bet = db('bet')->where('uid',$user['id'])->order('id desc')->limit(20)->select();
        $this->assign('bet',$bet);
        $this->assign('user',$data);
        $this->assign('code',$code);
        return $this->fetch('common/index');
    }
    //尾部
    public function bottom(){
        echo $this->fetch('common/bottom');
    }
}